package org.harsh.transmission.common;

import cn.hutool.core.lang.UUID;
import io.netty.channel.Channel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class NodeItem {
    private String peerAddr;
    private String tokenStr;
    private byte[] publicKey;
    private byte[] sharedKey;
    private long accessTime;
    private long invalidationTime;
    private int version;

    public NodeItem(String peerAddr, byte[] publicKey, byte[] sharedKey) {
        this.peerAddr = peerAddr;
        this.publicKey = publicKey;
        this.sharedKey = sharedKey;
        this.tokenStr = UUID.randomUUID().toString();
        this.accessTime = System.currentTimeMillis();
        this.invalidationTime = System.currentTimeMillis() + 3600 * 1000;
        this.version = 1;
    }
}
